package it.yuzuojian.com.service.impl;

import it.yuzuojian.com.dao.SingerMapper;
import it.yuzuojian.com.domain.Singer;
import it.yuzuojian.com.service.SingerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class SingerServiceImpl implements SingerService {
    @Autowired
    private SingerMapper singerMapper;
    @Override
    public Boolean insert(Singer singer) {
        int i=0;
        try {
            i=singerMapper.insert(singer);
        }catch (Exception e){
            e.printStackTrace();
        }
        return i>0;
    }

    @Override
    public Boolean update(Singer singer) {
        return singerMapper.update(singer)>0;
    }

    @Override
    public Boolean delete(Integer id) {
        return singerMapper.delete(id)>0;
    }

    @Override
    public Singer selectById(Integer id) {
        return singerMapper.selectById(id);
    }

    @Override
    public List<Singer> selectAll() {
        return singerMapper.selectAll();
    }

    @Override
    public List<Singer> selectByName(String name) {
        name="%"+name+"%";
        return singerMapper.selectByName(name);
    }

    @Override
    public List<Singer> selectBySex(Integer sex) {
        return singerMapper.selectBySex(sex);
    }
}
